package com.example.tests;


import com.example.fw.ContactObject;
import com.example.fw.Contacts;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;

import org.testng.annotations.Test;

public class ContactEditionTests extends TestBase {

	@Test
	public void testFirstContactCanBeEdited() throws Exception {
		ContactObject validContact = new ContactObject()
				.setFirstname("firstname_updated")
				.setLastname("lastname_updated").setAddress("address_updated")
				.setHome("home_updated").setMobile("mobile_updated")
				.setWork("work_updated").setEmail("email_updated")
				.setEmail2("email2_updated")
				.setbDay(app.getContactHelper().day)
				.setbMonth(app.getContactHelper().month)
				.setbYear(app.getContactHelper().year)
				.setAddress2("address2_updated").setPhone2("phone2_updated");
		validContact.setFullName(validContact.getFullName());
		Contacts oldList = app.getContactHelper().getContacts();
		ContactObject contactBeforeEdit = app.getContactHelper()
				.getFirstContact();
		app.getContactHelper().editContact(validContact);
		Contacts newList = app.getContactHelper().getContacts();
		assertThat(newList, equalTo(oldList.withRemoved(contactBeforeEdit).withAdded(validContact)));
	}
}
